package com.wsz.pojo;

import com.wsz.pojo.Cell;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Player {
    private String id;
    private Integer sx;
    private Integer sy;
    private List<Integer> steps;

    private String bot_id;//-1 人 其他 AI
    private String bot_code;

    private Boolean check_len(int step){
        if(step <= 10) return true;
        return (step - 10) % 3 == 0;
    }

    public List<Cell> getCell(){
        List<Cell> res = new ArrayList<>();

        int[] dx = {-1, 0, 1, 0};
        int[] dy = {0, 1, 0, -1};

        int x = sx, y = sy,tmp = 0;

         res.add(new Cell(x,y));

         for(int d : steps){
             x += dx[d];
             y += dy[d];

             res.add(new Cell(x,y));

             if(!check_len(++tmp)){
                 res.remove(0);
             }
         }
        return res;
    }
}
